<?php

/**
 * This is the model class for table "form".
 *
 * The followings are the available columns in table 'form':
 * @property integer $id
 * @property string $name
 * @property string $description
 * @property string $email
 * @property string $redirect
 * @property string $success_message
 * @property string $password
 * @property string $unique_ip
 * @property boolean $captcha
 * @property boolean $review
 * @property boolean $status
 * @property string $creation_datetime
 * @property string $last_update
 * @property string $log
 */
class FormBase extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Form the static model class
	 */
	public static function model($className='Form')
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return SITE_TABLE_PREFIX.'form';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name, email', 'length', 'max'=>255),
			array('description, redirect, success_message, captcha, log, permission, status, creation_datetime, last_update', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, description, email, redirect, success_message, captcha, log, permission, status, creation_datetime, last_update', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'description' => 'Description',
			'email' => 'Email',
			'redirect' => 'Redirect',
			'success_message' => 'Success Message',
			'password' => 'Password',
			'unique_ip' => 'Unique Ip',
			'captcha' => 'Captcha',
			'review' => 'Review',
			'status' => 'Status',
			'creation_datetime' => 'Creation Datetime',
			'last_update' => 'Last Update',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('redirect',$this->redirect,true);
		$criteria->compare('success_message',$this->success_message,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('unique_ip',$this->unique_ip,true);
		$criteria->compare('captcha',$this->captcha);
		$criteria->compare('review',$this->review);
		$criteria->compare('status',$this->status);
		$criteria->compare('creation_datetime',$this->creation_datetime,true);
		$criteria->compare('last_update',$this->last_update,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}